package com.example.springbootlucenedemo.http;

import com.example.springbootlucenedemo.bean.TbMission;
import com.example.springbootlucenedemo.service.impl.TbMissionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("tbmisson")
@RestController
public class TbmissonController {
    @Autowired
    TbMissionServiceImpl tbMissionService;
    @GetMapping("/getById/{id}")
    public TbMission getById(@PathVariable("id") Long id){
        return tbMissionService.tbMissionDao.getById(id);
    }

    @GetMapping("/page/{pageIndex}/{pageSize}")
    public Page<TbMission> findPage(@PathVariable("pageIndex") Integer pageIndex, @PathVariable("pageSize") Integer pageSize){
        Pageable pageable = PageRequest.of(pageIndex,pageSize);
        Page<TbMission> page = tbMissionService.tbMissionDao.findAll(pageable);
        return page;
    }
}
